package name.panitz.ludens.strategy;
import java.util.*;

class Position {
  byte triblet;
  byte pos;
  Position(byte triblet,byte pos){
    this.triblet=triblet;
    this.pos=pos;
  }
  @Override
  public String toString(){
    return "("+triblet+","+pos+")";
  }

  List<Position> connectedPositions(){
    final List<Position> result = new LinkedList<Position>();
    if (pos%2==1){
      if (triblet==0||triblet==2) result.add(new Position((byte)1,pos));
      else {
	result.add(new Position((byte)0,pos));
	result.add(new Position((byte)2,pos));
      }
    }
    result.add(new Position(triblet,(byte)((pos+7)%8)));
    result.add(new Position(triblet,(byte)((pos+1)%8)));

    return result;
  }

  List<Position[]> rows(){
    List<Position[]> result = new LinkedList<Position[]>();
    if (pos%2==1){
      final Position[] r1
	  ={new Position((byte)0,pos),new Position((byte)1,pos),new Position((byte)2,pos)};

      final Position[] r2
       ={new Position(triblet,((byte)((pos+7)%8))),new Position(triblet,pos),new Position(triblet,(byte)((pos+1)%8))};
      result.add(r1);
      result.add(r2);
    }else{
      final Position[] r1
       ={new Position(triblet,((byte)((pos+1)%8))),new Position(triblet,pos),new Position(triblet,(byte)((pos+2)%8))};

      final Position[] r2
       ={new Position(triblet,((byte)((pos+7)%8))),new Position(triblet,pos),new Position(triblet,(byte)((pos+6)%8))};
      result.add(r1);
      result.add(r2);
    }

    return result;
  }
}

